package com.example.demo;

import java.util.ArrayList;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lizhien (zhien.li@nascent.cn)
 * @version 1.0.0
 * @date 2022/3/18 16:02
 * @description com.example.demo
 */

@RestController
@RequestMapping("/user")
public class UserController {

    private Logger log = LoggerFactory.getLogger(UserController.class);

    @GetMapping("{id:\\d+}")
    public User getUserById(@PathVariable("id") Integer id) {

        log.info("控制器===进入UserController，执行getUserById");
        User user = new User();
        ArrayList<String> list2 = new ArrayList<String>(Arrays.asList("o1", "o2"));
        ArrayList<String> list1 = new ArrayList<String>() {{
            add("abc");
        }};
        user.setRoles(new ArrayList<String>(Arrays.asList("role1", "role2")));
        user.setName("用户" + id);
        user.setPassword(String.valueOf(id + 1000));
        return user;
    }
}
